<?php
/*
 * File name : verifyAddress.php
* Description : Verifies the address using Google Geocoding APIs
* Created By : Abhiraj Chauhan
*/
include_once "basePage.php";

class VerifyAddress extends basePage{  
	public function input() // Gets the input of address and sends the get request to Google GeoCoding APIs
	{
		$apt=$_POST['apt'];
		$add=$_POST['add'];
		$city=$_POST['city'];
		$state=$_POST['state'];
		$zip = $_POST['zip'];
		
		$add = str_replace(" ", "+", $add);
		$city = str_replace(" ", "+", $city);
		
		$url = "http://maps.googleapis.com/maps/api/geocode/json?address=".$apt.",+".$add.",+".$city.",+".$state."&sensor=true";
		
		$response = json_decode(file_get_contents($url),true);
		
		$location_type = $response['results'][0]['geometry']['location_type'];
		
		if($location_type == "ROOFTOP" || $location_type == "RANGE_INTERPOLATED")
			echo "<h3>Address Verified</h3>";
		else echo "<h3>Address Not Verified. Please Verify Manually</h3>";
		
	}
}

$page = new VerifyAddress();
$page->header();
$page->include_transalte();
$page->top_menu_agency();
$page->input();
$page->footer();

?>